package cn.zcx.servlet;

import com.wf.captcha.GifCaptcha;
import com.wf.captcha.utils.CaptchaUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * description:
 * author:zcx
 * lenovo
 * 时间：2022.01.25.21.10
 */
@WebServlet("/checks")
public class Checks extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        GifCaptcha c = new GifCaptcha();
        //c.out(resp.getOutputStream());
        //直接输出到servlet上，并将验证码的内容保存到session session.setAttribute("captcha",c.text());
        CaptchaUtil.out(c, req, resp);

        /*
        HttpSession session = req.getSession();
        Enumeration<String> e = session.getAttributeNames();
        while (e.hasMoreElements()) {
            String n = e.nextElement();
            System.out.println(n);
            System.out.println(session.getAttribute(n));
        }

         */

    }
}
